home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / kgdb-4.5 / ds3100.md / include / user.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-16  |  8.7 KB  |  291 lines

  1. /*     @(#)user.h    4.1.1.5    (ULTRIX)    7/7/88     */
  2.  
  3. /************************************************************************
  4.  *                                    *
  5.  *            Copyright (c) 1987 by                *
  6.  *        Digital Equipment Corporation, Maynard, MA        *
  7.  *            All rights reserved.                *
  8.  *                                    *
  9.  *   This software is furnished under a license and may be used and    *
  10.  *   copied  only  in accordance with the terms of such license and    *
  11.  *   with the  inclusion  of  the  above  copyright  notice.   This    *
  12.  *   software  or  any  other copies thereof may not be provided or    *
  13.  *   otherwise made available to any other person.  No title to and    *
  14.  *   ownership of the software is hereby transferred.            *
  15.  *                                    *
  16.  *   This software is  derived  from  software  received  from  the    *
  17.  *   University    of   California,   Berkeley,   and   from   Bell    *
  18.  *   Laboratories.  Use, duplication, or disclosure is  subject  to    *
  19.  *   restrictions  under  license  agreements  with  University  of    *
  20.  *   California and with AT&T.                        *
  21.  *                                    *
  22.  *   The information in this software is subject to change  without    *
  23.  *   notice  and should not be construed as a commitment by Digital    *
  24.  *   Equipment Corporation.                        *
  25.  *                                    *
  26.  *   Digital assumes no responsibility for the use  or  reliability    *
  27.  *   of its software on equipment which is not supplied by Digital.    *
  28.  *                                    *
  29.  ************************************************************************/
  30. /*
  31.  *
  32.  *    Modification History
  33.  *
  34.  *    Fred Glover - Jan 12, 1988
  35.  *        Add UF_FDLOCK flag for Sys-V file lock
  36.  *
  37.  *    Tim Burke -- Dec 28, 1987
  38.  *    Removed u_ttyp field.  It is now in the proc struct.
  39.  *
  40.  *     15 Sep 87 -- Mark Parenti
  41.  *    Added oldsig to record which signals were invoked using the
  42.  *    POSIX signal() interface which requires handler to be reset
  43.  *    to SIG_DFL ala System V. Added u.narg field to contain
  44.  *    number of arguments to a syscall.
  45.  *
  46.  *
  47.  *     15 dec 86 -- depp
  48.  *    Changed u_smodsize -> u_osmsize.  The former was not being
  49.  *    used and the later is required for process SM page table 
  50.  *    swap allocation.  The size or related offsets in the user
  51.  *    table is unchanged.
  52.  *    
  53.  *    Depp -- April 2, 1986
  54.  *        Removed a.out header data from struct user.
  55.  *
  56.  *    Stephen Reilly - Oct 14, 1985
  57.  *        Reomved fields that are no longer needed
  58.  *
  59.  *      Depp -- September 30, 1985
  60.  *        Added u_lock for locking memory segments
  61.  *
  62.  *      Stephen Reilly - Sept 9, 1985
  63.  *        Modified to handle the new 4.3BSD namei code.
  64.  *
  65.  *      Depp -- April 4, 1985
  66.  *        Removed SHMEM ifdefs
  67.  *
  68.  *    001 - Larry Cohen - April 4, 1985
  69.  *        add UF_INUSE flag to mark file in use.  supports open
  70.  *        block if in use capability
  71.  *
  72.  *
  73.  * 01 Mar 85 -- depp
  74.  *    Added System V Shared memory data elements to user structure.
  75.  *
  76.  */
  77.  
  78. #ifdef KERNEL
  79. #include "../machine/pcb.h"
  80. #include "../h/dmap.h"
  81. #include "../h/time.h"
  82. #include "../h/resource.h"
  83. #include "../h/namei.h"
  84. #ifdef mips
  85. #include "../machine/debug.h"
  86. #endif mips
  87. #else KERNEL
  88. #include <machine/pcb.h>
  89. #include <machine/sys/dmap.h>
  90. #include <sys/time.h>
  91. #include <sys/resource.h>
  92. #include <machine/sys/namei.h>
  93. #ifdef mips
  94. #include <machine/sys/ptrace.h>
  95. #include <machine/debug.h>
  96. #endif mips
  97. #endif KERNEL
  98.  
  99. /*
  100.  * Per process structure containing data that
  101.  * isn't needed in core when the process is swapped out.
  102.  */
  103.  
  104. #define    SHSIZE        32
  105. #define    MAXCOMLEN    16        /* <= MAXNAMLEN, >= sizeof(a_comm) */
  106.  
  107. struct ucred {
  108.     u_short    cr_ref;            /* reference count */
  109.     short   cr_uid;            /* effective user id */
  110.     short   cr_gid;            /* effective group id */
  111.     int     cr_groups[NGROUPS];    /* groups, 0 terminated */
  112.     short   cr_ruid;        /* real user id */
  113.     short   cr_rgid;        /* real group id */
  114. };
  115.  
  116. struct    user {
  117.     struct    pcb u_pcb;
  118.     struct    proc *u_procp;        /* pointer to proc structure */
  119.     int    *u_ar0;            /* address of users saved R0 */
  120.     char    u_comm[MAXNAMLEN + 1];
  121.  
  122. /* syscall parameters, results and catches */
  123.     int    u_arg[8];        /* arguments to current system call */
  124.     int    *u_ap;            /* pointer to arglist */
  125.     label_t    u_qsave;        /* for non-local gotos on interrupts */
  126.     union {                /* syscall return values */
  127.         struct    {
  128.             int    R_val1;
  129.             int    R_val2;
  130.         } u_rv;
  131. #define    r_val1    u_rv.R_val1
  132. #define    r_val2    u_rv.R_val2
  133.         off_t    r_off;
  134.         time_t    r_time;
  135.     } u_r;
  136.     char    u_error;        /* return error code */
  137.     char    u_eosys;        /* special action on end of syscall */
  138.     char    u_narg;            /* number of arguments in u_arg above */
  139.  
  140. /* 1.1 - processes and protection */
  141.     struct ucred *u_cred;        /* user credentials (uid, gid, etc) */
  142. #define    u_uid        u_cred->cr_uid
  143. #define    u_ruid        u_cred->cr_ruid
  144. #define    u_gid        u_cred->cr_gid
  145. #define    u_rgid        u_cred->cr_rgid
  146. #define    u_groups     u_cred->cr_groups
  147.  
  148. /* 1.2 - memory management */
  149.     size_t    u_tsize;        /* text size (clicks) */
  150.     size_t    u_dsize;        /* data size (clicks) */
  151.     size_t    u_ssize;        /* stack size (clicks) */
  152.     struct    dmap u_dmap;        /* disk map for data segment */
  153.     struct    dmap u_smap;        /* disk map for stack segment */
  154.     struct    dmap u_cdmap, u_csmap;    /* shadows of u_dmap, u_smap, for
  155.                        use of parent during fork */
  156.     label_t u_ssave;        /* label variable for swapping */
  157.     size_t    u_odsize, u_ossize;    /* for (clumsy) expansion swaps */
  158.     time_t    u_outime;        /* user time at last sample */
  159.  
  160. /* 1.3 - signal management */
  161.     void    (*u_signal[NSIG])();    /* disposition of signals */
  162.     int    u_sigmask[NSIG];    /* signals to be blocked */
  163.     int    u_sigonstack;        /* signals to take on sigstack */
  164.     int    u_sigintr;        /* signals that interrupt syscalls */
  165.     int    u_oldsig;        /* POSIX "old style" signals */
  166.     int    u_oldmask;        /* saved mask from before sigpause */
  167.     int    u_code;            /* ``code'' to trap */
  168.     struct    sigstack u_sigstack;    /* sp & on stack state variable */
  169. #ifdef mips
  170.     int    (*u_sigtramp)();    /* signal trampoline code */
  171.     int    u_trapcause;        /* cause for SIGTRAP */
  172.     int    u_trapinfo;        /* extra info concerning SIGTRAP */
  173. #endif mips
  174. #define    u_onstack    u_sigstack.ss_onstack
  175. #define    u_sigsp        u_sigstack.ss_sp
  176.  
  177. /* 1.4 - descriptor management */
  178.     struct    file *u_ofile[NOFILE];    /* file structures for open files */
  179.     char    u_pofile[NOFILE];    /* per-process flags of open files */
  180. #define    UF_EXCLOSE     0x1        /* auto-close on exec */
  181. #define    UF_MAPPED     0x2        /* mapped from device */
  182. #define    UF_INUSE     0x4        /* mutex semaphore */
  183. #define UF_FDLOCK    0x8        /* sys-V file locked */
  184.     int    u_lastfile;        /* highest numbered open file */
  185. #define u_omax    u_lastfile
  186.     struct    gnode *u_cdir;        /* current directory */
  187.     struct    gnode *u_rdir;        /* root directory of current process */
  188. #define u_ttyp    u_procp->p_ttyp
  189.     dev_t    u_ttyd;            /* controlling tty dev */
  190.     short    u_cmask;        /* mask for file creation */
  191.  
  192. /* 1.5 - timing and statistics */
  193.     struct    rusage u_ru;        /* stats for this proc */
  194.     struct    rusage u_cru;        /* sum of stats for reaped children */
  195.     struct    itimerval u_timer[3];
  196.     int    u_tracedev;        /* for syscall tracer */
  197.     int    u_XXX[3];
  198.     struct    timeval    u_start;    /* whole timeval instead of secs */
  199.     short    u_acflag;
  200.  
  201. /* 1.6 - resource controls */
  202.     struct    rlimit u_rlimit[RLIM_NLIMITS];
  203.     struct    quota *u_quota;        /* user's quota structure */
  204.     int    u_qflags;        /* per process quota flags */
  205.  
  206.     struct uprof {            /* profile arguments */
  207.         short    *pr_base;    /* buffer base */
  208.         unsigned pr_size;    /* buffer size */
  209.         unsigned pr_off;    /* pc offset */
  210.         unsigned pr_scale;    /* pc scaling */
  211.     } u_prof;
  212.  
  213. /* 1.7 - System V related elements */
  214.     size_t    u_smsize;    /* size of SM space (clicks)    */
  215.     size_t    u_osmsize;    /* old SM size for expansion swaps */
  216.     int    u_lock;        /* memory locking flags (see ../h/lock.h) */
  217.  
  218. /* 1.9 - Namei caching */
  219.     struct nameicache {        /* last successful directory search */
  220.         int nc_prevoffset;    /* offset at which last entry found */
  221.         ino_t nc_inumber;    /* inum of cached directory */
  222.         dev_t nc_dev;        /* dev of cached directory */
  223.         time_t nc_time;        /* time stamp for cache entry */
  224.     } u_ncache;
  225.     struct nameidata u_nd;
  226. /* 1.10 - User stack */
  227. #ifdef mips
  228. /* kernel stack */
  229. #endif mips
  230.     int    u_stack[1];
  231. };
  232.  
  233. #ifdef KERNEL
  234. struct ucred *crget();
  235. struct ucred *crcopy();
  236. struct ucred *crdup();
  237. #endif KERNEL
  238.  
  239. /* u_eosys values */
  240. #ifdef vax
  241. #define    JUSTRETURN    0
  242. #define    RESTARTSYS    1
  243. #define    SIMULATERTI    2
  244. #define    REALLYRETURN    3
  245. #endif vax
  246. #ifdef mips
  247. #define    FULLRESTORE    1
  248. #define    RESTARTSYS    2
  249. #define NORMALRETURN    3
  250. #endif mips
  251.  
  252. /* u_error codes */
  253. #ifdef KERNEL
  254. #include "../h/errno.h"
  255. #else KERNEL
  256. #include <errno.h>
  257. #endif KERNEL
  258.  
  259. #ifdef KERNEL
  260. #ifdef vax
  261. extern    struct user u;
  262. extern    struct user swaputl;
  263. extern    struct user forkutl;
  264. extern    struct user xswaputl;
  265. extern    struct user xswap2utl;
  266. extern    struct user pushutl;
  267. extern    struct user vfutl;
  268. #endif vax
  269.  
  270. #ifdef mips
  271. /*
  272.  * This "declaration" tells front end it can use r0 relative addressing.
  273.  */
  274. #define    u    (*(struct user *)UADDR)
  275. /*
  276.  * Since u is strange, use up for debugging purposes.
  277.  */
  278. struct user *up;
  279.  
  280. extern char VA_swaputl[];
  281. #define    swaputl    (*(struct user *)VA_swaputl)
  282.  
  283. extern char VA_forkutl[];
  284. #define    forkutl    (*(struct user *)VA_forkutl)
  285.  
  286. extern char VA_vfutl[];
  287. #define    vfutl    (*(struct user *)VA_vfutl)
  288. #endif mips
  289.  
  290. #endif KERNEL
  291.